home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0039 / source / dcpiccnv.mod < prev    next >
Text File  |  1997-04-16  |  25KB  |  639 lines

  1. IMPLEMENTATION MODULE DCPicCnv;
  2.  
  3.  
  4. (*---------------------------------------------------------------------*)
  5. (*   LOW LEVEL Picture Conversion Routines For DegasConvert            *)
  6. (*                                                                     *)
  7. (*                                                                     *)
  8. (*   The reason I choose to split the conversion routines is because   *)
  9. (*   the higher level routines need to access the screen to show the   *)
  10. (*   user what is happening. This way the low-level conversion         *)
  11. (*   module doesn't need to know about the screen, this hides          *)
  12. (*   implentation details.                                             *)
  13. (*                                                                     *)
  14. (*   Note: There are functions for each type of resolution, this is    *)
  15. (*         for efficiency reasons. Also for efficiency reasons there   *)
  16. (*         will be routines to convert ONE picture line. The picture   *)
  17. (*         to be operated on will be passed each time along with the   *)
  18. (*         print palette to go with it.                                *)
  19. (*                                                                     *)
  20. (*   The first version of this program was rather simple in the way it *)
  21. (*   allocated black and white patterns to the colours in the picture  *)
  22. (*   to be converted. Specifically, it just used the bits in the index *)
  23. (*   number of a pixel as the pattern to plot.( i.e. a dark colour may *)
  24. (*   come out light in the conversion ). A better way would be to look *)
  25. (*   at the colours in the palette and allocate a shade to it depending*)
  26. (*   on the intensity of the colour of the pixel. This is what is      *)
  27. (*   implemented in this version of the program.                       *)
  28. (*                                                                     *)
  29. (*   For a low-res picture there are 16 colours of different intensity *)
  30. (*   spread through the palette. I want to allocate print bit patterns *)
  31. (*   ( a number from 0 to 15 ) to each entry in the palette so that    *)
  32. (*   light colours print light and dark colours print dark. To         *)
  33. (*   simplify(!) this process I intend to sort the palette by          *)
  34. (*   intensity, allocate the print patterns to the palette in order    *)
  35. (*   of increasing number of on-bits in the print bit pattern.         *)
  36. (*                                                                     *)
  37. (*   Degas Picture Functions:                                          *)
  38. (*      1) Return the colour index of pixel                            *)
  39. (*      2) Return the Red,Green,Blue components of a palette entry     *)
  40. (*      3) Assign a print bit pattern,got from user,to a palette entry *)
  41. (*      4) Assign Default print bit patterns to the picture palette    *)
  42. (*      5) Return the print bit pattern for a pixel                    *)
  43. (*      6) Set a pixel in the hi-res picture                           *)
  44. (*      7) Toggle a pixel in the hi-res picture                        *)
  45. (*      8) Clear all pixels in the hi-res picture                      *)
  46. (*                                                                     *)
  47. (*   22/ 8/89 LGM Change routines to use pointers to PixelGroups.      *)
  48. (*                                                                     *)
  49. (*                                                                     *)
  50. (*                                                                     *)
  51. (*   Version 1.1      August 1987                    L.G.Miller        *)
  52. (*---------------------------------------------------------------------*)
  53.  
  54. (*  IMPORT Trace; *)
  55.  
  56.  
  57. FROM    DCGlobal                IMPORT  LowRes,         (* constants *)
  58.                                         LowResMaxX,
  59.                                         LowResMaxY,
  60.                                         LowResNoPlanes,
  61.  
  62.                                         MedRes,
  63.                                         MedResMaxX,
  64.                                         MedResMaxY,
  65.                                         MedResNoPlanes,
  66.  
  67.                                         HiRes,
  68.                                         HiResMaxX,
  69.                                         HiResMaxY,
  70.                                         HiResNoPlanes,
  71.  
  72.                                         Palette,    (* types *)
  73.                                         BitPlanesEnum,
  74.  
  75.                                         LowRes16Pixels,
  76.                                         LowResScreenLine,
  77.                                         LowResScreen,
  78.                     LowResPixelGroupPtr,
  79.                         LowResScreenLinePtr,
  80.                 
  81.  
  82.                                         MedRes16Pixels,
  83.                                         MedResScreenLine,
  84.                                         MedResScreen,
  85.                     MedResPixelGroupPtr,
  86.                         MedResScreenLinePtr,
  87.  
  88.  
  89.                                         HiRes16Pixels,
  90.                                         HiResScreenLine,
  91.                                         HiResScreen,
  92.                     HiResPixelGroupPtr,
  93.                         HiResScreenLinePtr,
  94.  
  95.                                         DegasPicture,
  96.                                         PrintPalette,
  97.                                         PrintBitPatternSet,
  98.                                         PaletteEntry,
  99.      
  100.                          BITSPERWORD;
  101.  
  102.  FROM QSort        IMPORT SortArrayWithKeys;
  103.  
  104.  IMPORT DCQPicCnv;
  105.  
  106.  FROM   IntLogic    IMPORT IAND, RS;
  107.  
  108.  FROM   SYSTEM          IMPORT ADR,
  109.                                ADDRESS, LONGWORD, WORD;
  110.  
  111. TYPE
  112.     PaletteEntryPtr = POINTER TO PaletteEntry;
  113.  
  114. CONST
  115.     CLongOne = LONGCARD(1);
  116.  
  117.  
  118. (*----------------------------------------------------------------------*)
  119. (* Utility routines for the implementation of Setting Default Palette   *)
  120. (*                                                                      *)
  121. (* The brighter the colour the lighter the print should be. Bright      *)
  122. (* colours should be sorted to the 'top' of the array.                  *)
  123. (*                                                                      *)
  124. (* The cubing of the components gives weighting to the INTENSITY of the *)
  125. (* component. If something like this were not done the the colour 3,3,3 *)
  126. (* would by brighter than 5,0,0. This would be wrong; try it and see!   *)
  127. (*----------------------------------------------------------------------*)
  128. PROCEDURE CompareColours( PE1Ptr, PE2Ptr : PaletteEntryPtr ) : BOOLEAN;
  129.  
  130.   CONST CMaxColour = 7 * 7 * 7 * 3 + 1;
  131.  
  132.   VAR colour1, colour2 : CARDINAL;
  133.  
  134.   BEGIN
  135.          WITH PE1Ptr^ DO
  136.            colour1 := CMaxColour -
  137.                  (   ( RedComponent   * RedComponent   * RedComponent   )
  138.                    + ( GreenComponent * GreenComponent * GreenComponent )
  139.                    + ( BlueComponent  * BlueComponent  * BlueComponent  ) )
  140.          END; (* with *)
  141.  
  142.          WITH PE2Ptr^ DO
  143.            colour2 := CMaxColour -
  144.                  (   ( RedComponent   * RedComponent   * RedComponent   )
  145.                    + ( GreenComponent * GreenComponent * GreenComponent )
  146.                    + ( BlueComponent  * BlueComponent  * BlueComponent  ) )
  147.          END; (* with *)
  148.  
  149.          RETURN ( colour1 < colour2 );
  150.   END CompareColours;
  151.  
  152.  
  153. PROCEDURE SortByColour ( VAR ppalette : PrintPalette; nitems : CARDINAL );
  154.   BEGIN 
  155.     SortArrayWithKeys(ppalette, ppalette[0], LONG(nitems), CompareColours );
  156.   END SortByColour;
  157.  
  158.  
  159.  
  160. PROCEDURE CompareIndex( PE1Ptr, PE2Ptr : PaletteEntryPtr ) : BOOLEAN;
  161.   BEGIN
  162.      RETURN ( PE1Ptr^.ColourIndex < PE2Ptr^.ColourIndex  );
  163.   END CompareIndex;
  164.  
  165.  
  166. PROCEDURE SortByIndex ( VAR ppalette : PrintPalette; nitems : CARDINAL );
  167.   BEGIN
  168.     SortArrayWithKeys(ppalette, ppalette[0], LONG(nitems), CompareIndex );
  169.   END SortByIndex;
  170.  
  171.  
  172.  
  173. PROCEDURE LowRes16PixelsAddr (     x, y : CARDINAL;
  174.                    VAR picture : LowResScreen;
  175.                    VAR PixelNo : CARDINAL;
  176.                    VAR PGPtr   : LowRes16PixelsPtr );
  177.   VAR gno : CARDINAL;
  178.   BEGIN
  179.     PixelNo := x MOD BITSPERWORD;
  180.     gno     := x DIV BITSPERWORD;
  181.     PGPtr   := ADR( picture[y][gno] );
  182.   END LowRes16PixelsAddr;
  183.  
  184.  
  185. PROCEDURE MedRes16PixelsAddr (     x, y    : CARDINAL;
  186.                    VAR picture : MedResScreen;
  187.                    VAR PixelNo : CARDINAL;
  188.                    VAR PGPtr   : MedRes16PixelsPtr );
  189.   VAR gno : CARDINAL;
  190.   BEGIN
  191.     PixelNo := x MOD BITSPERWORD;
  192.     gno     := x DIV BITSPERWORD;
  193.     PGPtr   := ADR( picture[y][gno] );
  194.   END MedRes16PixelsAddr;
  195.  
  196.  
  197. PROCEDURE HiRes16PixelsAddr (     x, y    : CARDINAL;
  198.                   VAR picture : HiResScreen;
  199.                   VAR PixelNo : CARDINAL;
  200.                   VAR PGPtr   : HiRes16PixelsPtr );
  201.   VAR gno : CARDINAL;
  202.   BEGIN
  203.     PixelNo := x MOD BITSPERWORD;
  204.     gno     := x DIV BITSPERWORD;
  205.     PGPtr   := ADR( picture[y][gno] );
  206.   END HiRes16PixelsAddr;
  207.  
  208.  
  209. (*----------------------------------------------------------------------*)
  210. (* Find out the Colour index of a low-res pixel.                        *)
  211. (*----------------------------------------------------------------------*)
  212. PROCEDURE QueryXYLowResPixelIndex( x, y : CARDINAL;
  213.                        Picture : DegasPicture ) : CARDINAL;
  214.   VAR    
  215.         LowResPGPtr       : LowRes16PixelsPtr;
  216.         LowResPixelNo    : CARDINAL;
  217.  
  218.   BEGIN
  219.     LowRes16PixelsAddr( x, y, Picture.LowResPicture,
  220.                 LowResPixelNo, LowResPGPtr);
  221.     RETURN QueryLowResPixelIndex(LowResPixelNo, LowResPGPtr);
  222.   END  QueryXYLowResPixelIndex;
  223.  
  224.  
  225.  
  226. (*----------------------------------------------------------------------*)
  227. (*  Split colour value into its red, green and blue components.         *)
  228. (*----------------------------------------------------------------------*)
  229. PROCEDURE ColourComponents (     colour           : CARDINAL;
  230.                              VAR red, green, blue : CARDINAL );
  231.   CONST
  232.     CRightShift          = 4;          (* shift 1 nibble right *)
  233.     CColourComponentMask = 7;          (* Least Sig. 3 bits    *)
  234.  
  235.   BEGIN
  236.     blue   := IAND(colour, CColourComponentMask);
  237.     colour := RS(colour, CRightShift);
  238.     green  := IAND(colour, CColourComponentMask);
  239.     colour := RS(colour, CRightShift);
  240.     red    := IAND(colour, CColourComponentMask);
  241.    END ColourComponents;
  242.  
  243. (*----------------------------------------------------------------------*)
  244. (* Get red, green, blue components of a low-res pixel                   *)
  245. (*----------------------------------------------------------------------*)
  246. PROCEDURE QueryLowResPixelColour ( PixelNo : CARDINAL;
  247.                        PGPtr   : LowRes16PixelsPtr;
  248.                                    VAR palette : Palette;
  249.                                    VAR red, green, blue : CARDINAL );
  250.  
  251.   VAR i, colour : CARDINAL;
  252.  
  253.   BEGIN
  254.     i := DCQPicCnv.QQryLRPIndex( PixelNo, PGPtr ); (* get colour index *)
  255.     colour := palette[i]; (* bits = XXXX XRRR XGGG XBBB *)
  256.     DCQPicCnv.QQColourComp( colour, red, green, blue );
  257.   END QueryLowResPixelColour;
  258.  
  259.  
  260. (*----------------------------------------------------------------------*)
  261. (* Get the colour index of a low-res pixel                              *)
  262. (*----------------------------------------------------------------------*)
  263. PROCEDURE QueryLowResPixelIndex  ( PixelNo : CARDINAL;
  264.                    PGPtr : LowRes16PixelsPtr ) : CARDINAL;
  265. (*
  266.   CONST
  267.     CPlane1Index = 1;
  268.         CPlane2Index = 2;
  269.         CPlane3Index = 4;
  270.         CPlane4Index = 8;
  271.  
  272.   VAR index : CARDINAL;
  273. *)
  274.   BEGIN
  275. (* 
  276.    index := 0;
  277.     IF ( PixelNo IN PGPtr^[BitPlane1]) THEN
  278.          INC(index,CPlane1Index);
  279.     END;
  280.     IF ( PixelNo IN PGPtr^[BitPlane2]) THEN
  281.          INC(index,CPlane2Index);
  282.     END;
  283.     IF ( PixelNo IN PGPtr^[BitPlane3]) THEN
  284.          INC(index,CPlane3Index);
  285.     END;
  286.     IF ( PixelNo IN PGPtr^[BitPlane4]) THEN
  287.          INC(index,CPlane4Index);
  288.     END;
  289.  
  290.     RETURN index;
  291. *)
  292.     RETURN DCQPicCnv.QQryLRPIndex( PixelNo, PGPtr ); 
  293.   END QueryLowResPixelIndex;
  294.  
  295.  
  296.  
  297. (*----------------------------------------------------------------------*)
  298. (* Get the Print bit pattern associated with a low-res pixel            *)
  299. (*                                                                      *)
  300. (* The print-palette is in colour index order                           *)
  301. (*----------------------------------------------------------------------*)
  302. PROCEDURE QueryLowResPixelPBPattern ( PixelNo : CARDINAL;
  303.                                       PGPtr   : LowRes16PixelsPtr;
  304.                                       VAR printpalette : PrintPalette;
  305.                                       VAR pbp     : PrintBitPatternSet );
  306.   VAR
  307.      colourindex : CARDINAL;
  308.  
  309.   BEGIN
  310.     colourindex := QueryLowResPixelIndex(PixelNo, PGPtr);
  311.     pbp := printpalette[colourindex].PrintBitPattern;
  312.   END QueryLowResPixelPBPattern;
  313.  
  314.  
  315. (*----------------------------------------------------------------------*)
  316. (* medium res versions of the query pixel routines                      *)
  317. (*----------------------------------------------------------------------*)
  318.  
  319.  
  320. (*----------------------------------------------------------------------*)
  321. (* Find out the Colour index of a med-res pixel.                        *)
  322. (*----------------------------------------------------------------------*)
  323. PROCEDURE QueryXYMedResPixelIndex( x, y : CARDINAL;
  324.                        Picture : DegasPicture ) : CARDINAL;
  325.   VAR    
  326.         MedResPGPtr       : MedRes16PixelsPtr;
  327.         MedResPixelNo    : CARDINAL;
  328.  
  329.   BEGIN
  330.     MedRes16PixelsAddr( x, y, Picture.MedResPicture,
  331.                 MedResPixelNo, MedResPGPtr);
  332.     RETURN QueryMedResPixelIndex(MedResPixelNo, MedResPGPtr);
  333.   END  QueryXYMedResPixelIndex;
  334.  
  335.  
  336.  
  337. PROCEDURE QueryMedResPixelColour ( PixelNo : CARDINAL;
  338.                        PGPtr   : MedRes16PixelsPtr;
  339.                                    VAR palette : Palette;
  340.                                    VAR red, green, blue : CARDINAL );
  341.  
  342.   VAR i, colour : CARDINAL;
  343.  
  344.   BEGIN
  345.     i := QueryMedResPixelIndex( PixelNo, PGPtr ); (* get colour index *)
  346.     colour := palette[i]; (* bits = XXXX XRRR XGGG XBBB *)
  347.     DCQPicCnv.QQColourComp( colour, red, green, blue );
  348.   END QueryMedResPixelColour;
  349.  
  350.  
  351. PROCEDURE QueryMedResPixelIndex  ( PixelNo : CARDINAL;
  352.                    PGPtr : MedRes16PixelsPtr ) : CARDINAL;
  353. (*
  354.   CONST
  355.     CPlane1Index = 1;
  356.         CPlane2Index = 2;
  357.  
  358.   VAR index : CARDINAL;
  359. *)
  360.   BEGIN
  361. (* 
  362.    index := 0;
  363.     IF ( PixelNo IN PGPtr^[BitPlane1]) THEN
  364.          INC(index,CPlane1Index);
  365.     END;
  366.     IF ( PixelNo IN PGPtr^[BitPlane2]) THEN
  367.          INC(index,CPlane2Index);
  368.     END;
  369.     RETURN index;
  370. *)
  371.     RETURN DCQPicCnv.QQryMRPIndex( PixelNo, PGPtr ); 
  372.   END QueryMedResPixelIndex;
  373.  
  374.  
  375. PROCEDURE QueryMedResPixelPBPattern ( PixelNo : CARDINAL;
  376.                                       PGPtr   : MedRes16PixelsPtr;
  377.                                       VAR printpalette : PrintPalette;
  378.                                       VAR pbp     : PrintBitPatternSet );
  379.   VAR
  380.      colourindex : CARDINAL;
  381.  
  382.   BEGIN
  383.     colourindex := QueryMedResPixelIndex(PixelNo, PGPtr);
  384.     pbp := printpalette[colourindex].PrintBitPattern;
  385.  
  386.   END QueryMedResPixelPBPattern;
  387.  
  388.  
  389.  
  390. (*----------------------------------------------------------------------*)
  391. (* Change the BitPattern printed for a colour index.                    *)
  392. (*----------------------------------------------------------------------*)
  393. PROCEDURE SetPBPattern ( VAR printpalette : PrintPalette;
  394.                              colourindex  : CARDINAL;
  395.                              pbp          : PrintBitPatternSet );
  396.   BEGIN
  397.     printpalette[colourindex].PrintBitPattern := pbp;
  398.   END SetPBPattern;
  399.  
  400.  
  401. (*----------------------------------------------------------------------*)
  402. (*  Return the Bit Pattern to be printed for a particular colour        *)
  403. (*----------------------------------------------------------------------*)
  404. PROCEDURE QueryPBPattern ( VAR printpalette : PrintPalette;
  405.                                      colourindex  : CARDINAL;
  406.                            VAR       pbp          : PrintBitPatternSet );
  407.   BEGIN
  408.     pbp := printpalette[colourindex].PrintBitPattern;
  409.   END QueryPBPattern;
  410.  
  411.  
  412. (*----------------------------------------------------------------------*)
  413. (*----------------------------------------------------------------------*)
  414. (* Routines to process the output hi-res picture                        *)
  415. (*----------------------------------------------------------------------*)
  416. (*----------------------------------------------------------------------*)
  417.  
  418. (*----------------------------------------------------------------------*)
  419. (* Reset all the pixels in the output hi-res picture                    *)
  420. (*----------------------------------------------------------------------*)
  421. PROCEDURE ClearHiRes ( VAR screen : HiResScreen );
  422.  
  423.   CONST CMaxGroup =  HiResMaxX DIV BITSPERWORD;
  424.  
  425.   VAR  HiPGPtr : HiRes16PixelsPtr;
  426.        ngroups : CARDINAL;
  427.        pixno   : CARDINAL;
  428.        x, y    : CARDINAL;
  429.   BEGIN
  430.     HiRes16PixelsAddr( 0, 0, screen, pixno, HiPGPtr );
  431.     FOR y := 0 TO HiResMaxY  DO
  432.        FOR x := 0 TO CMaxGroup DO
  433.          HiPGPtr^ := {};
  434.          HiPGPtr := ADDRESS(LONGCARD(HiPGPtr) + SIZE(HiPGPtr^));
  435.        END;
  436.     END;
  437.   END ClearHiRes;
  438.  
  439.  
  440. PROCEDURE SetHiResPixel (     PixelNo : CARDINAL;
  441.                               PGPtr   : HiRes16PixelsPtr );
  442.   BEGIN
  443.     INCL( PGPtr^, PixelNo );
  444.   END SetHiResPixel;
  445.  
  446.  
  447.  
  448. (*----------------------------------------------------------------------*)
  449. (* This routine will plot the pattern in a square.                      *)
  450. (*----------------------------------------------------------------------*)
  451. PROCEDURE SetLowToHiResPBPattern (     x, y   : CARDINAL;
  452.                                    VAR screen : HiResScreen;
  453.                                        pbp    : PrintBitPatternSet );
  454.   VAR i         : CARDINAL;
  455.  
  456.   BEGIN (*
  457.     IF ( 0 IN pbp ) THEN  SetHiResPixel( x,   y,   screen ); END;
  458.     IF ( 1 IN pbp ) THEN  SetHiResPixel( x+1, y,   screen ); END;
  459.     IF ( 2 IN pbp ) THEN  SetHiResPixel( x,   y+1, screen ); END;
  460.     IF ( 3 IN pbp ) THEN  SetHiResPixel( x+1, y+1, screen ); END;
  461. *)
  462.   END SetLowToHiResPBPattern;
  463.  
  464. (*----------------------------------------------------------------------*)
  465. (* This routine will plot the pattern in a square. OPTIMIZED VERSION    *)
  466. (*                                                                      *)
  467. (* Assumptions: The pattern to be set will fit in one hires 16 pixel grp*)
  468. (*----------------------------------------------------------------------*)
  469. PROCEDURE OptSetLowToHiResPBPattern (     StartBitno  : CARDINAL;
  470.                                       VAR ScreenLine1 : HiRes16PixelsPtr;
  471.                                       VAR ScreenLine2 : HiRes16PixelsPtr;
  472.                                       VAR pbp         : PrintBitPatternSet);
  473.   BEGIN
  474.     IF ( 0 IN pbp ) THEN  (* SetHiResPixel( x,   y,   screen ); *)
  475.        INCL( ScreenLine1^, StartBitno );
  476.     END;
  477.  
  478.     IF ( 2 IN pbp ) THEN  (* SetHiResPixel( x,   y+1, screen ); *)
  479.        INCL( ScreenLine2^, StartBitno );
  480.     END;
  481.  
  482.     INC(StartBitno);
  483.  
  484.     IF ( 1 IN pbp ) THEN  (* SetHiResPixel( x+1, y,   screen ); *)
  485.        INCL( ScreenLine1^, StartBitno );
  486.     END;
  487.  
  488.     IF ( 3 IN pbp ) THEN  (* SetHiResPixel( x+1, y+1, screen ); *)
  489.        INCL( ScreenLine2^, StartBitno );
  490.     END;
  491.   END OptSetLowToHiResPBPattern;
  492.  
  493.  
  494. (*----------------------------------------------------------------------*)
  495. (* This routine will plot the pattern in a rectangle                    *)
  496. (*----------------------------------------------------------------------*)
  497. PROCEDURE SetMedToHiResPBPattern (     x, y   : CARDINAL;
  498.                                    VAR screen : HiResScreen;
  499.                                        pbp    : PrintBitPatternSet );
  500.  
  501.   BEGIN (*
  502.     IF ( 0 IN pbp ) THEN  SetHiResPixel( x,   y,   screen ); END;
  503.     IF ( 1 IN pbp ) THEN  SetHiResPixel( x,   y+1, screen ); END;
  504.   *)
  505.   END SetMedToHiResPBPattern;
  506.  
  507.  
  508.  
  509. (*----------------------------------------------------------------------*)
  510. (* This routine will plot the pattern in a rectangle - OPTIMIZED VERSION*)
  511. (*----------------------------------------------------------------------*)
  512. PROCEDURE OptSetMedToHiResPBPattern (     StartBitno  : CARDINAL;
  513.                                       VAR ScreenLine1 : HiRes16PixelsPtr;
  514.                                       VAR ScreenLine2 : HiRes16PixelsPtr;
  515.                                       VAR pbp         : PrintBitPatternSet);
  516.   BEGIN
  517.     IF ( 0 IN pbp ) THEN  (* SetHiResPixel( x,   y,   screen ); *)
  518.        INCL( ScreenLine1^, StartBitno );
  519.     END;
  520.  
  521.     IF ( 1 IN pbp ) THEN  (* SetHiResPixel( x,   y+1, screen ); *)
  522.        INCL( ScreenLine2^, StartBitno );
  523.     END;
  524.  
  525.  END OptSetMedToHiResPBPattern;
  526.  
  527.  
  528. (*----------------------------------------------------------------------*)
  529. (* Optimized, a bit...                                                  *)
  530. (*----------------------------------------------------------------------*)
  531. PROCEDURE ConvertLowToHiResOneLine ( VAR inpic, outpic : DegasPicture;
  532.                                      VAR printpalette  : PrintPalette;
  533.                                      inlineno          : CARDINAL );
  534.  
  535.   CONST CMaxLowResGroup =  LowResMaxX DIV BITSPERWORD;
  536.  
  537.  
  538.   VAR    HiResPG1Ptr, 
  539.     HiResPG2Ptr    : HiRes16PixelsPtr;
  540.         HiResPixelNo    : CARDINAL;
  541.  
  542.         LowResPGPtr       : LowRes16PixelsPtr;
  543.         LowResPixelNo    : CARDINAL;
  544.  
  545.         LowResPixelGroup,
  546.     colour    : CARDINAL;
  547.  
  548.   BEGIN
  549.     LowRes16PixelsAddr( 0, inlineno, inpic.LowResPicture,
  550.                 LowResPixelNo, LowResPGPtr);
  551.  
  552.     HiRes16PixelsAddr( 0, (inlineno * 2), outpic.HiResPicture,
  553.                HiResPixelNo, HiResPG1Ptr);
  554.  
  555.     HiResPG2Ptr := ADDRESS(LONGCARD(HiResPG1Ptr) 
  556.             + SIZE(outpic.HiResPicture[0]));
  557.  
  558.     FOR LowResPixelGroup := 0 TO CMaxLowResGroup DO
  559.       HiResPixelNo := 0; 
  560.       FOR LowResPixelNo :=    0 TO BITSPERWORD-1 DO
  561.        colour := QueryLowResPixelIndex( LowResPixelNo, LowResPGPtr );
  562.          (* used to be OptSetLowToHiResPBPattern( ... *) 
  563.        DCQPicCnv.QSetLTHPBP  ( HiResPixelNo,
  564.                        HiResPG1Ptr,
  565.                                HiResPG2Ptr,
  566.                                printpalette[colour].PrintBitPattern);
  567.        
  568.        INC(HiResPixelNo, 2);
  569.        IF HiResPixelNo > BITSPERWORD-1 THEN
  570.           HiResPixelNo := 0;
  571.           HiResPG1Ptr := ADDRESS(LONGCARD(HiResPG1Ptr)+SIZE(HiResPG1Ptr^));          
  572.           HiResPG2Ptr := ADDRESS(LONGCARD(HiResPG2Ptr)+SIZE(HiResPG1Ptr^));          
  573.        END;
  574.       END; (* for *)
  575.  
  576.       LowResPGPtr := ADDRESS(LONGCARD(LowResPGPtr)+SIZE(LowResPGPtr^));          
  577.     END; (* for  *)
  578.  
  579.   END ConvertLowToHiResOneLine;
  580.  
  581.  
  582. (*----------------------------------------------------------------------*)
  583. (* Optimized, a bit...                                                  *)
  584. (*----------------------------------------------------------------------*)
  585. PROCEDURE ConvertMedToHiResOneLine ( VAR inpic, outpic : DegasPicture;
  586.                                      VAR printpalette  : PrintPalette;
  587.                                      inlineno          : CARDINAL );
  588.  
  589.  
  590.   CONST CMaxMedResGroup =  MedResMaxX DIV BITSPERWORD;
  591.  
  592.  
  593.   VAR    HiResPG1Ptr, 
  594.     HiResPG2Ptr    : HiRes16PixelsPtr;
  595.         HiResPixelNo    : CARDINAL;
  596.  
  597.         MedResPGPtr       : MedRes16PixelsPtr;
  598.         MedResPixelNo    : CARDINAL;
  599.  
  600.         MedResPixelGroup,
  601.     colour    : CARDINAL;
  602.  
  603.   BEGIN
  604.     MedRes16PixelsAddr( 0, inlineno, inpic.MedResPicture,
  605.                 MedResPixelNo, MedResPGPtr);
  606.  
  607.     HiRes16PixelsAddr( 0, (inlineno * 2), outpic.HiResPicture,
  608.                HiResPixelNo, HiResPG1Ptr);
  609.  
  610.     HiResPG2Ptr := ADDRESS(LONGCARD(HiResPG1Ptr) 
  611.             + SIZE(outpic.HiResPicture[0]));
  612.  
  613.     FOR MedResPixelGroup := 0 TO CMaxMedResGroup DO
  614.       HiResPixelNo := 0; 
  615.       FOR MedResPixelNo :=    0 TO BITSPERWORD-1 DO
  616.        colour := QueryMedResPixelIndex( MedResPixelNo, MedResPGPtr );
  617.          (* used to be OptSetMedToHiResPBPattern( ... *) 
  618.        DCQPicCnv.QSetMTHPBP  ( HiResPixelNo,
  619.                    HiResPG1Ptr,
  620.                                HiResPG2Ptr,
  621.                                printpalette[colour].PrintBitPattern);
  622.        
  623.        INC(HiResPixelNo, 1);
  624.        IF HiResPixelNo > BITSPERWORD-1 THEN
  625.           HiResPixelNo := 0;
  626.           HiResPG1Ptr := ADDRESS(LONGCARD(HiResPG1Ptr)+SIZE(HiResPG1Ptr^));          
  627.           HiResPG2Ptr := ADDRESS(LONGCARD(HiResPG2Ptr)+SIZE(HiResPG1Ptr^));          
  628.        END;
  629.  
  630.       END; (* for *)
  631.  
  632.       MedResPGPtr := ADDRESS(LONGCARD(MedResPGPtr)+SIZE(MedResPGPtr^));          
  633.     END; (* for  *)
  634.  
  635.   END ConvertMedToHiResOneLine;
  636.  
  637.  
  638. END DCPicCnv.
  639.